<style lang="scss" scoped>
    @import '~@/scss/global/colors.scss';
    .ui.page-content{
        background:$content-bg !important;
    }
    .subMenu{
        a{
            position:relative;
            cursor:pointer;
            color:$header-txt;
            margin:0 15px;
            &:hover{
                color:$header-heightLight;
            }
            &:last-child{
                margin-right:0;
            }
        }
        a.active{
            color:$header-heightLight;
        }
        &::before{
            display:none;
        }
        padding:0 !important;
        .active{
            padding:6px 15px 0 15px;
            position:relative;
            background:rgba(#fff, .1);
            height:30px;
            top:0;
            border-radius:3px;
        }
    }
</style>
<template>
    <div id="app" class="ui flex column vh-100">
        <div v-if="noLogin && !bybk" class="ui top menu navbar" style="border-radius:0;margin:0">
            <div class="item">
                <img src=""
                    alt="logo"
                    style="position:absolute;width:59px; left:0; top:6px;z-index:99">
                <span class="logo-txt">BUI手册</span> <span style="font-size:12px" class="m-b-5">VER: {{ version }}</span>
            </div>
            <div class="menu right">
                <el-dropdown size="small"
                    placement="top"
                    class="item"
                    @command="logout"
                    trigger="hover"
                    :show-timeout="10"
                    :hide-timeout="300">
                    <a>
                        <img class="ui avatar image" src="~assets/tuzi.gif">
                        <span>donkey</span>
                    </a>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item disabled>
                            <i class="icon question"></i>
                            帮助
                        </el-dropdown-item>
                        <el-dropdown-item disabled>
                            <i class="power off icon"></i>
                            退出
                        </el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </div>
        <div class="ui flex item one">
            <ui-sidebar-b v-if="!bybk" sort></ui-sidebar-b>
            <div class="ui flex column item one" id="app-router">
                <router-view></router-view>
            </div>
        </div>
    </div>
</template>
<script>
    import { version } from '@/bui/package.json'

    export default {
        name: 'app',
        /*provide() {
            return {
                app: this,
            }
        },*/
        data() {
            return {
                url: '',
                imageUrl: '/static/tuzi.gif',
                version: version
            }
        },
        mounted() {
            this.url = BASE_URL;
        },
        methods: {
            logout() {
                this.$store.dispatch('FedLogout')
                    .then(() => {
                        //处理url不要带着产品子系统参数。
                        let path = window.location.href;
                        if (path.indexOf('?') > 0) {
                            window.location.href = path.split('?')[0] + '#/login'
                        }else{
                            window.location.href = path.split('#')[0] + '#/login'
                        }
                    })
                    .catch(err => {
                        this.log(err)
                    })
            }
        },
        computed: {
            noLogin() {
                let path = this.$route.fullPath
                return path !== '/loginFed' || path !== '/login'
            },
            products() {
                return this.$store.state.permission.products;
            },
            subs() {
                return this.$store.state.permission.subs;
            },
            current_pid() {
                return this.$store.state.permission.current_pid;
            },
            current_sid() {
                return this.$store.state.permission.current_sid;
            },
            bybk() {
                return this.$route.query.bybk
            }
        }
    }
</script>
